package com.bwf.nio;

import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.FileVisitor;
import java.nio.file.attribute.BasicFileAttributes;

/**
 * @Version v1.0
 * @Description: TODO
 * @Author ZHANZHONGXIN
 * @Date 2022/5/18 15:33
 * @Copyright 博为峰
 */
public class FileVisitorImpl implements FileVisitor {
    //访问前
    @Override
    public FileVisitResult preVisitDirectory(Object dir, BasicFileAttributes attrs) throws IOException {
        System.out.println("访问前preVisitDirectory:" + dir);
        return FileVisitResult.CONTINUE;
    }
    //访问时
    @Override
    public FileVisitResult visitFile(Object file, BasicFileAttributes attrs) throws IOException {
        System.out.println("访问时visitFile:" + file);
        return FileVisitResult.CONTINUE;
    }
    //访问失败时
    @Override
    public FileVisitResult visitFileFailed(Object file, IOException exc) throws IOException {
        return FileVisitResult.CONTINUE;
    }
    //访问后
    @Override
    public FileVisitResult postVisitDirectory(Object dir, IOException exc) throws IOException {
        System.out.println("访问后postVisitDirectory:" + dir);
        return FileVisitResult.CONTINUE;
    }
}
